import JSEncrypt from 'jsencrypt';

// rsa 加密
export class RsaEncrypt {
  /** 密钥 */
  private jsencrypt = new JSEncrypt();
  
  constructor(key) {
    this.jsencrypt.setPublicKey(key);
  }
  
  /**
   * @description 加密
   */
  encrypt(cipherText: string): string {
    return this.jsencrypt.encrypt(cipherText) as string;
  }
  
  /**
   * @description 解密
   */
  decrypt(cipherText: string) {
    return this.jsencrypt.decrypt(cipherText) as string;
  }
}


export const rsaEncryption = new RsaEncrypt(
  'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkgCf4CS41UAB0UzwRrDbtaOWdDF3x1rpSbZcZOjonusNeWMqlEYk+gt7qcJA6b/VHv3wDHAwJqDOX+R28Wmhx1M9m1wydsEWpW7hOCAotMU8vaB+dZjucB6WM2gcEFCQ2axglsd/G9/7TLVkQZKGnUUwySxmQnHP8jBX6MzJRiWTPMquZRqbE9dnDjy9nz006tS4jZWSOLgQD/yYLHOtq2n/h6i6aWMxR9ofcz4eXdBXr/FBw6IXBT4EgDJulcu6iCCv2Iw8eYOOsJpv3oi/gVZpN+ShFkPZUxXdgO98TeRjj7K1AGl0/mkGWv0B51uu7DZMOqMAqrLmarNCd5tRlQIDAQAB'
);
